package com.chaihu.jpaDemo.modules.system.entity;

import com.chaihu.jpaDemo.common.annotation.DictLabel;
import com.chaihu.jpaDemo.modules.common.entity.MysqlLongIdEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;

/**
 * 描述: 接口请求日志记录
 * 作者: qinzhw
 * 创建时间: 2018/8/8 10:04
 */
@ApiModel
@Entity
@Table(name = "sys_operate_log")
@org.hibernate.annotations.Table(appliesTo = "sys_operate_log",comment="用户操作日志表")
@Data
public class OperateLog extends MysqlLongIdEntity{

	@Column(columnDefinition = "Integer default 0 comment '日志类型:0正常1异常'")
	@ApiModelProperty("日志类型:0正常1异常")
	private int type;

	@Column(columnDefinition = "varchar(100) comment '操作功能'")
	@ApiModelProperty("操作功能")
	private String operateName;

	@Column(columnDefinition = "varchar(100) comment '操作具体业务'")
	@ApiModelProperty("操作具体业务")
	private String operateBusiness;

	@Column(columnDefinition = "varchar(500) comment '访问路径'")
	@ApiModelProperty("访问路径")
	private String url;

	@Column(columnDefinition = "varchar(50) comment '访问类型'")
	@ApiModelProperty("访问类型")
	private String method;

	@Lob
	@Basic(fetch= FetchType.LAZY)
	@Column(columnDefinition = "text comment '参数'")
	@ApiModelProperty("参数")
	private String params;

	@Column(columnDefinition = "varchar(100) comment '用户IP'")
	@ApiModelProperty("用户IP")
	private String ip;

	@Column(columnDefinition = "bigint comment '用户编号'")
	@ApiModelProperty("用户编号")
	private Long userId;

	@Column(columnDefinition = "varchar(100) comment '用户姓名'")
	@ApiModelProperty("用户姓名")
	private String userName;

	@DictLabel
	@Column(columnDefinition = "int(1) comment '删除标记'")
	@ApiModelProperty("删除标记")
	private int delFlag;

	@Lob
	@Basic(fetch= FetchType.LAZY)
	@Column(columnDefinition = "text comment '异常信息'")
	@ApiModelProperty("异常信息")
	private String exception;

	@Lob
	@Basic(fetch= FetchType.LAZY)
	@Column(columnDefinition = "text comment '返回结果'")
	@ApiModelProperty("返回结果")
	private String operateResult;

	@Temporal(TemporalType.TIMESTAMP)
	@org.hibernate.annotations.CreationTimestamp
	@ApiModelProperty("用户操作时间")
	@Column(columnDefinition = "timestamp comment '用户操作时间'")
	private Date operateDate;

	@Column(columnDefinition = "bigint default 0 comment '请求响应时间'", nullable = false)
	@ApiModelProperty("请求响应时间 ")
	private long time;


}
